<template>
  <div class="container">
    <el-card>
      <el-tabs v-model="activeName">
        <el-tab-pane label="系统消息" name="first">
          <span v-for="item in message">
            <el-card>
              <b style="color: #475669;">{{ item.title }}</b><br />
              <el-card>
                <b style="color: #475669;">{{ item.createdAt }}</b><br />
                <p style="width: 1000px;">{{ item.message }}</p>
                <img :src="item.banner" style="width: 450px;height:450px;" />
              </el-card>
            </el-card>
          </span>
        </el-tab-pane>
        <el-tab-pane label="医院通知" name="second">
          <span v-for="item in hospital">
            <el-card>
              <b style="color: #475669;">{{ item.title }}</b><br />
              <el-card>
                <b style="color: #475669;">{{ item.createdAt }}</b><br />
                <p style="width: 1000px;">{{ item.message }}</p>
                <img :src="item.banner" style="width: 450px;height:450px;" />
              </el-card>
            </el-card>
          </span>
        </el-tab-pane>
        <el-tab-pane label="我的订阅" name="third">
          <span v-for="item in aboutMeMsg">
            <el-card>
              <b style="color: #475669;">{{ item.title }}</b><br />
              <el-card>
                <b style="color: #475669;">{{ item.createdAt }}</b><br />
                <p style="width: 1000px;">{{ item.message }}</p>
                <img :src="item.banner" style="width: 450px;height:450px;" />
              </el-card>
            </el-card>
          </span>
        </el-tab-pane>
      </el-tabs>
    </el-card>
    <el-card style="margin-top: 20px; text-align: center;">
      <el-carousel height="350px" direction="vertical" :autoplay="false">
        <el-carousel-item v-for="item in urls.length" :key="item">
          <el-image v-for="msg in urls" :key="msg" :src="msg.url" lazy></el-image>
        </el-carousel-item>
      </el-carousel>
      <el-row :gutter="20">
        <el-col :span="4">
          <div class="grid-content bg-purple">
          </div>
        </el-col>
        <el-col :span="16">
          <div class="grid-content bg-purple" style="display: inline-block; ">
            <ul class="ull">
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
            </ul>
          </div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple">
          </div>
        </el-col>
      </el-row>
    </el-card>
  </div>
</template>
<script>
import request from "@/utils/request";
export default {
  data() {
    return {
      user: {},
      message: {},
      aboutMeMsg: {},
      hospital: {},
      visible: false,
      activeIndex: 'fourth',
      urls: [
        { url: 'https://www.covidvaccine.gov.hk/assets/banner-tc.png' },
        { url: 'https://www.covidvaccine.gov.hk/assets/banner-tc.png' },
        { url: 'https://www.covidvaccine.gov.hk/assets/banner-tc.png' },
        { url: 'https://www.covidvaccine.gov.hk/assets/banner-tc.png' },
      ]
    }
  },
  created() {
    let userStr = sessionStorage.getItem("user") || "{}"
    this.user = JSON.parse(userStr)
    this.initData();
  },
  methods: {
    initData() {
      request.get("/notify/banner").then(res => {
        this.message = res.data;
        console.log(this.message)
        request.get("/notify/" + 2).then(res => {
          this.hospital = res.data;
        })
        request.get("/notify/" + this.user.id).then(res => {
          this.aboutMeMsg = res.data;
        })
      })
    },

    handleClose(done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done();
        })
        .catch(_ => { });
    }
  }
}
</script>
<style>
.item {
  margin-top: 10px;
  margin-right: 40px;
}

.container {
  background-color: #f0f2f5;
  padding: 30px;
  min-height: calc(100vh - 84px);
}

.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n+1) {
  background-color: #d3dce6;
}

.ull {
  height: 200px;
  list-style: none;
  margin-top: 100px;
  display: flex;
}

.ull li {
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background-color: red;
  margin-right: 20px;
}

.ull li:nth-child(1) {
  background-color: red;
  animation: love1 4s 0s infinite;
}

.ull li:nth-child(2) {
  background-color: darkturquoise;
  animation: love2 4s 0.2s infinite;
}

.ull li:nth-child(3) {
  background-color: darksalmon;
  animation: love3 4s 0.4s infinite;
}

.ull li:nth-child(4) {
  background-color: deeppink;
  animation: love4 4s 0.6s infinite;
}

.ull li:nth-child(5) {
  background-color: yellow;
  animation: love5 4s 0.8s infinite;
}

.ull li:nth-child(6) {
  background-color: deeppink;
  animation: love4 4s 1s infinite;
}

.ull li:nth-child(7) {
  background-color: darksalmon;
  animation: love3 4s 1.2s infinite;
}

.ull li:nth-child(8) {
  background-color: darkturquoise;
  animation: love2 4s 1.4s infinite;
}

.ull li:nth-child(9) {
  background-color: red;
  animation: love1 4s 1.6s infinite;
}

@keyframes love1 {

  30%,
  50% {
    height: 60px;
    transform: translateY(-30px);
  }

  70%,
  100% {
    height: 0px;
    transform: translateY(0px);
  }
}

@keyframes love2 {

  30%,
  50% {
    height: 125px;
    transform: translateY(-60px);
  }

  70%,
  100% {
    height: 0px;
    transform: translateY(0px);
  }
}

@keyframes love3 {

  30%,
  50% {
    height: 160px;
    transform: translateY(-75px);
  }

  70%,
  100% {
    height: 0px;
    transform: translateY(0px);
  }
}

@keyframes love4 {

  30%,
  50% {
    height: 180px;
    transform: translateY(-60px);
  }

  70%,
  100% {
    height: 0px;
    transform: translateY(0px);
  }
}

@keyframes love5 {

  30%,
  50% {
    height: 200px;
    transform: translateY(-45px);
  }

  70%,
  100% {
    height: 0px;
    transform: translateY(0px);
  }
}
</style>
